﻿// -----------------------------------------------------------------------
// <copyright file="Contrast.cs" company="FCIS">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace ImagePackage.Core.PixelOperations
{
    using System;
    using Model;
    using Utilities;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class Contrast : IOperation
    {
        /// <summary>
        /// The input image to act upon
        /// </summary>
        protected readonly Image InputImage;

        /// <summary>
        /// Initializes a new instance of the <see cref="Contrast"/> class.
        /// </summary>
        /// <param name="inputImage">The input image.</param>
        public Contrast(Image inputImage)
        {
            this.InputImage = inputImage;
        }

        /// <summary>
        /// Gets or sets the contrast value.
        /// </summary>
        /// <value>
        /// The contrast value.
        /// </value>
        public sbyte ContrastValue
        {
            get;
            set;
        }

        /// <summary>
        /// Applies the operation.
        /// Requires the input image
        /// </summary>
        /// <returns>
        /// Image object
        /// </returns>
        public virtual Image Apply()
        {
            Logger.Debug("Start applying Contrast operation");
            try
            {
                Image buffer = new Image(this.InputImage.Width, this.InputImage.Height);

                //// TODO : Apply the contrast code.

                return buffer;
            }
            catch (Exception ex)
            {
                Logger.LogException("Something wrong happened in Contrast Operation", ex);
                throw;
            }
            finally
            {
                Logger.Debug("Finished applying Contrast operation");
            }
        }
    }
}
